package com.meichis.yndms.room.dao;

import androidx.room.*;

import com.meichis.yndms.model.OfficialCity;

import java.util.List;

@Dao
public interface OfficialCityDao {
    @Query("SELECT * FROM OfficialCity")
    List<OfficialCity> findAll();

    @Query("SELECT * FROM OfficialCity WHERE ID=:id")
    OfficialCity find(int id);

    @Query("SELECT * FROM OfficialCity WHERE Name LIKE :nameLike")
    List<OfficialCity> find(String... nameLike);

    @Query("SELECT * FROM OfficialCity WHERE Level=:level AND Name LIKE :nameLike ORDER BY LENGTH(Name)")
    List<OfficialCity> find(int level, String... nameLike);

    @Query("SELECT * FROM OfficialCity WHERE SuperID=:superID")
    List<OfficialCity> findBySuperID(int superID);

    @Query("DELETE FROM OfficialCity")
    int deleteAll();

    @Query("DELETE FROM OfficialCity WHERE ID=:id")
    int delete(int id);

    @Delete
    int delete(OfficialCity... OfficialCitys);

    @Update
    int update(OfficialCity... OfficialCitys);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    long[] insertAll(List<OfficialCity> list);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    long[] insert(OfficialCity... OfficialCitys);
}
